import 'package:flutter/material.dart';
class Fittedbox_aspectratio_constrainedbox extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      body: new Center(
        child: new Container(
          width: 150,
          height: 150,
          color: Colors.blue,
          child:

          new FittedBox(
            /*
        * FittedBox 类似于安卓中的ImageView
                *  Key key,
                  this.fit = BoxFit.
                                   fill,充满父布局
                                  contain,保持着child宽高比的大前提下，尽可能的填满
                                  cover,按照最短边填满父布局的方式，同时扩大宽高
                                  fitWidth,适应宽度
                                  fitHeight,适应高度
                                  none,包裹子控件，不缩放
                                  scaleDown,感觉和none效果一样
                  this.alignment = Alignment.center,
                  Widget child,
        *
        * AspectRatio
        * ConstrainedBox 添加额外的限制条件（constraints）到child上
        * */
            fit: BoxFit.scaleDown,
//        alignment: Alignment.topLeft,
            child: new Container(
              color: Colors.amber,
              child: new Text("box"),
            ),
          ),

        ),
      ),
    );
  }

}